#include <iostream>
#include <cstdio>
#include <cmath>
#include <stdio.h>
using namespace std;
int  main() {
//	freopen("abc.txt", "r", stdin);
	long long  T;
	cin>>T;
	long long  q;
	long long  tmp;
	long long  res;
	while (T--) {
		scanf("%lld", &q);
		tmp=sqrt(q/2);
		if (q>2*tmp*(tmp+1)) {
			res=q-2*tmp*(tmp+1);
			if (res>=1 && res<=tmp) res=2*(2*tmp+2)-1;
			else res=2*(2*tmp+2);
		}
		else {
			res=q-2*tmp*tmp;
			if (res>=1 && res<=tmp-1) res=2*(2*tmp+1)-1;
			else if (res==0) res=2*(2*tmp+1)-2;
			else res=2*(2*tmp+1);
		}
		if (q==1) res=4;
		if (q==3) res=6;
		cout<<res<<endl;
	}
	return 0;
}
